import Vue from 'vue'
import App from './App'
import i18n from './i18n'
import store from './store'
import router from './router'
import '@/vab'

import VXETable from 'vxe-table'
import 'vxe-table/lib/style.css'

Vue.use(VXETable)

import {
  LMap,
  LTileLayer,
  LMarker,
  LPopup,
  LTooltip,
  LControl,
  LIcon,
  LCircle,
  LCircleMarker,
  LPolyline,
  LPolygon,
} from 'vue2-leaflet'
import 'leaflet/dist/leaflet.css'

Vue.component('LMap', LMap)
Vue.component('LTileLayer', LTileLayer)
Vue.component('LMarker', LMarker)
Vue.component('LPopup', LPopup)
Vue.component('LTooltip', LTooltip)
Vue.component('LControl', LControl)
Vue.component('LIcon', LIcon)
Vue.component('LCircle', LCircle)
Vue.component('LCircleMarker', LCircleMarker)
Vue.component('LPolyline', LPolyline)
Vue.component('LPolygon', LPolygon)

import Print from 'vue-print-nb'
Vue.use(Print)

import 'echarts/lib/data/helper/completeDimensions'
import VCharts from 'v-charts'
Vue.use(VCharts)

// import zhCN from 'vxe-table/lib/locale/lang/zh-CN'
// import enUS from 'vxe-table/lib/locale/lang/en-US'

// VXETable.config({
//   // 可选，对参数中的列头、校验提示..等进行自动翻译（只对支持国际化的有效）
//   translate(key, args) {
//     // 例如，只翻译 "app." 开头的键值
//     if (key && key.indexOf('app.') > -1) {
//       return i18n.t(key, args)
//     }
//     return key
//   },
// })

/**
 * @description 正式环境默认使用mock，正式项目记得注释后再打包
 */
import { baseURL, pwa } from './config'
import { isExternal } from '@/utils/validate'

if (process.env.NODE_ENV === 'production' && !isExternal(baseURL)) {
  const { mockXHR } = require('@/utils/static')
  mockXHR()
}

if (pwa) require('./registerServiceWorker')

Vue.config.productionTip = false
new Vue({
  el: '#app',
  i18n,
  store,
  router,
  render: (h) => h(App),
})
